// $URL: http://mingw-lib.googlecode.com/svn/trunk/working/avcodec_to_widget_8/t_box_input.h $
// $Rev: 291 $
// $Author: akio.miyoshi $
// $Date:: 2010-07-28 03:35:51 +0000#$

#ifndef T_BOX_INPUT_H
#define T_BOX_INPUT_H

////#include "t_box_player.h"
#include "stable.h"

class T_Box_Input : public QObject
{
    Q_OBJECT
protected:
    ByteIOContext m_bioc;
public:
    explicit T_Box_Input();
    ~T_Box_Input();
    virtual bool isValid() = 0;
    virtual void close() = 0; //FIXME
    virtual quint8* getIOBuffer() = 0;
    virtual int getIOBufferSize() = 0;
    virtual ByteIOContext *getByteIOContext();
    ////virtual T_Box_Player_Context *getPlayerContext();
    virtual AVFormatContext	*getAVFormatContext();
    void setDebugMode(bool b);
    bool debugMode();
protected:
    QString p_seek_whence_name(int whence);
    int read_packet(uint8_t *buf, int buf_size);
    virtual int read_bytes(uint8_t *buf, int buf_size) = 0;
    int64_t seek(int64_t offset, int whence);
    virtual int64_t seek_getpos() = 0;
    virtual int64_t seek_setpos(int64_t offset) = 0;
    virtual int64_t seek_length() = 0;
    virtual AVInputFormat *getAVInputFormat();
    ////virtual AVFormatContext	*getAVFormatContext();
protected:
    static int callback_read_packet(void *opaque, uint8_t *buf, int buf_size);
    static int64_t callback_seek(void *opaque, int64_t offset, int whence);
private:
    class T_Box_InputPrivate *d_ptr;
    Q_DECLARE_PRIVATE(T_Box_Input)
};

#endif // T_BOX_INPUT_H

class T_Box_Input;
